package club.haomoon.front.service.impl;

import club.haomoon.core.entity.system.HotSearchData;
import club.haomoon.core.mapper.system.HotSearchDataMapper;
import club.haomoon.core.util.ConfigUtil;
import club.haomoon.front.service.ISearchService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.*;

/**
 * -------------------------
 * @Description:  首页服务实现类
 * @Author: Wangjianwei
 * @Date: 2025/02/24 15:48
 * -------------------------
 */
@Service
public class SearchServiceImpl implements ISearchService {


    @Resource
    HotSearchDataMapper hotSearchMapper;

    @Override
    public JSONObject hotLists() {

        List<HotSearchData> hotSearches = hotSearchMapper.selectList(new QueryWrapper<HotSearchData>().orderByDesc("sort"));
        JSONObject result = new JSONObject(){{
            put("status", ConfigUtil.get("hot_search", "status", "0"));
            put("data", hotSearches);
        }};

        return result;
    }
}
